package com.example.big_job;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.content.res.Resources;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.example.big_job.Adapter.FoodAdapter;
import com.example.big_job.Adapter.MainAdapter;
import com.example.big_job.DB.DBHelper;

import java.util.ArrayList;
import java.util.List;

public class FoodActivity extends AppCompatActivity {

    private RecyclerView rv;
    private List<Integer> datas=new ArrayList<>();




    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_food);


        RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.rv_food);






        initData();
        //设置布局管理器
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.VERTICAL, false));
        //设置adapter
        FoodAdapter myAdapter=new FoodAdapter(this,datas);

        mRecyclerView.setAdapter(myAdapter);
        //分割线
        mRecyclerView.setItemAnimator(new DefaultItemAnimator());
        mRecyclerView.addItemDecoration(new DividerItemDecoration(FoodActivity.this, DividerItemDecoration.VERTICAL));


    }
    private void initData() {
        datas = new ArrayList<>();
        Resources res = getResources();
        datas.add(0);
        datas.add(res.getIdentifier("c1", "drawable", getPackageName()));
        datas.add(res.getIdentifier("c2", "drawable", getPackageName()));
        datas.add(res.getIdentifier("c3", "drawable", getPackageName()));
        datas.add(res.getIdentifier("c4", "drawable", getPackageName()));
        datas.add(res.getIdentifier("c5", "drawable", getPackageName()));
        datas.add(res.getIdentifier("c6", "drawable", getPackageName()));
        datas.add(res.getIdentifier("c7", "drawable", getPackageName()));
        datas.add(res.getIdentifier("c8", "drawable", getPackageName()));
        datas.add(res.getIdentifier("c9", "drawable", getPackageName()));
        datas.add(res.getIdentifier("c10", "drawable", getPackageName()));
    }
}